package com.nbicc.service.modular.dp.widgetinstance.service;

import com.nbicc.core.common.RequestPageObj;
import com.nbicc.core.common.ResponseUtil;
import com.nbicc.db.modular.dp.widgetinstance.mapper.WidgetInstanceMapper;
import com.nbicc.db.modular.dp.widgetinstance.model.WidgetInstance;
import com.nbicc.service.parent.serivce.BaseSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
import java.util.Map;

/**
 * @Author: lilingyan
 */
@Service
public class WidgetInstanceService extends BaseSerivce{

    @Autowired
    private WidgetInstanceMapper widgetInstanceMapper;

    public ResponseEntity<ModelMap> selectById(Integer id) {
        return ResponseUtil.ok(widgetInstanceMapper.selectById(id));
    }

    public ResponseEntity<ModelMap> find(RequestPageObj<Map<String, Object>> requestPageObj) {
        setPageHelper(requestPageObj);
        return ResponseUtil.ok(widgetInstanceMapper.selectByObject(requestPageObj.getData()));
    }

    public ResponseEntity<ModelMap> insert(WidgetInstance widgetInstance) {
        widgetInstanceMapper.insert(widgetInstance);
        return ResponseUtil.ok(widgetInstance);
    }

    public ResponseEntity<ModelMap> updateById(WidgetInstance widgetInstance) {
        widgetInstanceMapper.updateById(widgetInstance);
        return ResponseUtil.ok();
    }

    public ResponseEntity<ModelMap> deleteById(Integer id) {
        widgetInstanceMapper.deleteById(id);
        return ResponseUtil.ok();
    }

}
